<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>junglego: creature.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">junglego
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">creature.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="creature_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="creature_8hpp.html">creature.hpp</a>&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;<a class="code" href="consumable_8hpp.html">consumable.hpp</a>&quot;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &quot;<a class="code" href="brain_8hpp.html">brain.hpp</a>&quot;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="types_8hpp.html">types.hpp</a>&quot;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 
<a name="l00015"></a><a class="code" href="creature_8cpp.html#a68a6ab3894219205d7152dd4910405af">00015</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="creature_8cpp.html#a68a6ab3894219205d7152dd4910405af">gCreatureMaxHealth</a>;
<a name="l00016"></a>00016 
<a name="l00017"></a><a class="code" href="class_creature.html#a597cc3b08ee17de46c3e7ec3cf0d9b58">00017</a> <a class="code" href="class_creature.html#a597cc3b08ee17de46c3e7ec3cf0d9b58">Creature::Creature</a>() { }
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="class_creature.html#aa991b23f4813fbdb6f875204ed49814d">00019</a> <a class="code" href="class_creature.html#aa991b23f4813fbdb6f875204ed49814d">Creature::~Creature</a>() { }
<a name="l00020"></a>00020 
<a name="l00021"></a><a class="code" href="class_creature.html#a8f413947ac73cd545a6d858d1202239a">00021</a> <span class="keywordtype">bool</span> <a class="code" href="class_creature.html#a8f413947ac73cd545a6d858d1202239a">Creature::eat</a>(<a class="code" href="class_consumable.html">Consumable</a> &amp;con) {
<a name="l00022"></a>00022     <a class="code" href="class_creature.html#a7ee7518a06a266abff11add056aaf320">m_health</a> += con.<a class="code" href="class_consumable.html#aa29ac0bb8965128e8655e003d334ae62">getHungerFill</a>();
<a name="l00023"></a>00023     <span class="keywordflow">if</span>(<a class="code" href="class_creature.html#a7ee7518a06a266abff11add056aaf320">m_health</a> &gt; <a class="code" href="creature_8cpp.html#a68a6ab3894219205d7152dd4910405af">gCreatureMaxHealth</a>) {
<a name="l00024"></a>00024         <a class="code" href="class_creature.html#a7ee7518a06a266abff11add056aaf320">m_health</a> = <a class="code" href="creature_8cpp.html#a68a6ab3894219205d7152dd4910405af">gCreatureMaxHealth</a>;
<a name="l00025"></a>00025     }
<a name="l00026"></a>00026     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00027"></a>00027 }
<a name="l00028"></a>00028 
<a name="l00029"></a><a class="code" href="class_creature.html#ae109a8875e1906f4ffee7bf3b8ba479c">00029</a> <span class="keywordtype">void</span> <a class="code" href="class_creature.html#ae109a8875e1906f4ffee7bf3b8ba479c">Creature::init</a>(<span class="keywordtype">float</span> rad, <a class="code" href="structs__colour.html">s_colour</a> col, <a class="code" href="structs__vector.html">s_vector</a> pos, <a class="code" href="structs__vector.html">s_vector</a> vel) {
<a name="l00030"></a>00030     <a class="code" href="class_object.html#a21ffb1c449600ac2cd2afb1aefdc5bde">setRadius</a>(rad);
<a name="l00031"></a>00031     *<a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>() = col;
<a name="l00032"></a>00032     <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a> = pos;
<a name="l00033"></a>00033     <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a> = vel;
<a name="l00034"></a>00034     <a class="code" href="class_creature.html#a411023b60a5f9d18f3210a1a658454b0">m_brain</a> = <span class="keyword">new</span> <a class="code" href="class_brain.html">Brain</a>(1, 2, 4, 1);
<a name="l00035"></a>00035 }
<a name="l00036"></a>00036 
<a name="l00037"></a><a class="code" href="class_creature.html#aee07784fade6640a4dbdc837397b6b5b">00037</a> <span class="keywordtype">void</span> <a class="code" href="class_creature.html#aee07784fade6640a4dbdc837397b6b5b">Creature::move</a>() {
<a name="l00038"></a>00038     <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a> = <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a> + <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>;
<a name="l00039"></a>00039 <span class="preprocessor">#ifdef DBG</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>    std::cout&lt;&lt;<span class="stringliteral">&quot;Creature &quot;</span>&lt;&lt;
<a name="l00041"></a>00041         <a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>()-&gt;<a class="code" href="structs__colour.html#a0fb80f5fa16ec787b61f782cb0ce1c98">r</a>&lt;&lt;<span class="stringliteral">&quot; &quot;</span>&lt;&lt;
<a name="l00042"></a>00042         <a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>()-&gt;<a class="code" href="structs__colour.html#a6d55099c8e1e3d82dd7532c4a4fe3289">g</a>&lt;&lt;<span class="stringliteral">&quot; &quot;</span>&lt;&lt;
<a name="l00043"></a>00043         <a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>()-&gt;<a class="code" href="structs__colour.html#a9c0662f4e0e31aad1ec0040568552994">b</a>&lt;&lt;<span class="stringliteral">&quot; | &quot;</span>&lt;&lt;
<a name="l00044"></a>00044         <a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>()&lt;&lt;<span class="stringliteral">&quot; | &quot;</span>&lt;&lt;
<a name="l00045"></a>00045         <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a>&lt;&lt;<span class="stringliteral">&quot; &quot;</span>&lt;&lt;
<a name="l00046"></a>00046         <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a>&lt;&lt;<span class="stringliteral">&quot; | &quot;</span>&lt;&lt;
<a name="l00047"></a>00047         <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a>&lt;&lt;<span class="stringliteral">&quot; &quot;</span>&lt;&lt;
<a name="l00048"></a>00048         <a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a>&lt;&lt;<span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00049"></a>00049 <span class="preprocessor">#endif</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span>}
<a name="l00051"></a>00051 
<a name="l00052"></a><a class="code" href="class_creature.html#a4e16b04f8a7a0fb76d1da13a671a3d2a">00052</a> <span class="keywordtype">void</span> <a class="code" href="class_creature.html#a4e16b04f8a7a0fb76d1da13a671a3d2a">Creature::paint</a>() {
<a name="l00053"></a>00053     <a class="code" href="structs__colour.html">s_colour</a> * col = <a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>();
<a name="l00054"></a>00054     glPushMatrix();
<a name="l00055"></a>00055     glTranslatef((<span class="keywordtype">float</span>)(<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;pos.x),
<a name="l00056"></a>00056                  (<span class="keywordtype">float</span>)(<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;pos.y),
<a name="l00057"></a>00057                  0.0f);
<a name="l00058"></a>00058     glColor3f(col-&gt;<a class="code" href="structs__colour.html#a0fb80f5fa16ec787b61f782cb0ce1c98">r</a>, col-&gt;<a class="code" href="structs__colour.html#a6d55099c8e1e3d82dd7532c4a4fe3289">g</a>, col-&gt;<a class="code" href="structs__colour.html#a9c0662f4e0e31aad1ec0040568552994">b</a>);
<a name="l00059"></a>00059     <a class="code" href="gl_helper_8cpp.html#af09d4e544e73d211b48d2f6adc044a08">drawCircle</a>(<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>());
<a name="l00060"></a>00060     glPopMatrix();
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="class_creature.html#afa51f4f3a3ea04b1453d87888aecb1c8">00063</a> <span class="keywordtype">void</span> <a class="code" href="class_creature.html#afa51f4f3a3ea04b1453d87888aecb1c8">Creature::saveCreature</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * filename) {
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="class_creature.html#aba358468be3606b1716828e3d49ca557">00067</a> <span class="keywordtype">void</span> <a class="code" href="class_creature.html#aba358468be3606b1716828e3d49ca557">Creature::loadCreature</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> * filename) {
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00071"></a><a class="code" href="creature_8cpp.html#a4b43aa3ae80463887e96cb6922783f3e">00071</a> <span class="keywordtype">int</span> <a class="code" href="creature_8cpp.html#a4b43aa3ae80463887e96cb6922783f3e">getCreatureMaxHealth</a>() {
<a name="l00072"></a>00072     <span class="keywordflow">return</span> <a class="code" href="creature_8cpp.html#a68a6ab3894219205d7152dd4910405af">gCreatureMaxHealth</a>;
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00075"></a><a class="code" href="creature_8cpp.html#ab8ef0f19cdbd5e069f3facdf266b7503">00075</a> <span class="keywordtype">void</span> <a class="code" href="creature_8cpp.html#ab8ef0f19cdbd5e069f3facdf266b7503">setCreatureMaxHealth</a>(<span class="keywordtype">int</span> newVal) {
<a name="l00076"></a>00076     <a class="code" href="creature_8cpp.html#a68a6ab3894219205d7152dd4910405af">gCreatureMaxHealth</a> = newVal;
<a name="l00077"></a>00077 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 20 2012 21:57:14 for junglego by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
